<template>
  <div class="draft_title" v-if="unfold">
    <div class="draft_item" v-for="ite in props.content" :key="ite.id">
      <div class="draft_img">
        <img v-if="ite.cover" :src="ite.cover" alt=""/>
      </div>
      <span class="title">{{ite.title}}</span>
    </div>
  </div>
  <div class="draft_title" v-if="!unfold">
    <div class="draft_item">
      <div class="draft_img">
        <img v-if="props.content[0].cover" :src="props.content[0].cover" alt=""/>
      </div>
      <span class="title">{{props.content[0].title}}</span>
    </div>
  </div>
  <div class="title-icon" v-if="!unfold" @click="fold">
    <span>展开</span>
    <el-icon>
      <ArrowDown />
    </el-icon>
  </div>
</template>

<script lang="ts" setup>
  import { ref, computed } from 'vue'

  let unfold = ref<boolean>(false)

  interface Props {
    content: any[]
  }

  const props = withDefaults(defineProps<Props>(), {
    content: ()=>[]
  })

  const emit = defineEmits(['fold'])

  const fold = () => {
    unfold.value = true
    emit('fold', true)
  }


</script>

<style lang="scss" scoped>
  .draft_title{
    width: 100%;
    .draft_item{
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: 6px;
      .draft_img{
        width: 32px !important;
        height: 32px !important;
        border-radius: 6px;
        background-color: #f6f6f6;
        overflow: hidden;
        margin-right: 4px;
        img{
          width: 32px !important;
          height: 32px !important;
        }
      }
      .title{
        flex: 1;
        line-height: 1.6;
        font-size: 12px;
        color: #666;
        text-align: left;
      }
    }
  }

  .title-icon{
    display: flex;
    align-items: center;
    color: #FF6B00;
    margin-top: 6px;
    cursor: pointer;
    span{
      font-size: 12px;
      
    }
    .el-icon{
      
    }
  }
</style>
